<div id="Company-div" ng-controller="companyMageCtrl">
  <div class="well with-header  with-footer">
    <div class="header">公司信息表</div>
    <a id="editabledatatable_new" ng-click="addCompany()" class="btn btn-default" style="margin-bottom:10px;">
      <i class="fa fa-plus"></i>添加新的公司
    </a>
    <form role="form" ng-submit="sureAddCompany()" method="post">
    <table  class="table table-striped table-hover table-bordered">
        <thead>
            <tr Company="row">
                <th >序号</th>
                <th >名称</th>
                <th >地址</th>
                <th >所属省份</th>
                <th >负责人</th>
                <th>电话</th>
                <th class="edit">    </th>
            </tr>
        </thead>
        <tbody>
          <tr ng-repeat="company in companys">
            <td>{{(currentPage-1)*size+$index+1}}</td>
            <td>
              <span ng-if="!company.editActive">{{company.companyName}}</span>
              <input ng-model="companyEdit.companyName" ng-if="company.editActive" type="text" ng-init="companyEdit.companyName=company.companyName">
            </td>
            <td>
              <span ng-if="!company.editActive">{{company.companyAddress}}</span>
              <input ng-model="companyEdit.companyAddress" ng-if="company.editActive" type="text" ng-init="companyEdit.companyAddress=company.companyAddress">
            </td>
            <td>
              <span ng-if="!company.editActive">{{company.companyRegion}}</span>
              <input ng-model="companyEdit.companyRegion" ng-if="company.editActive" type="text" ng-init="companyEdit.companyRegion=company.companyRegion">
            </td>
            <td>
              <span ng-if="!company.editActive">{{company.companyUser}}</span>
              <input ng-model="companyEdit.companyUser" ng-if="company.editActive" type="text" ng-init="companyEdit.companyUser=company.companyUser">
            </td>
            <td>
              <span ng-if="!company.editActive">{{company.companyPhone}}</span>
              <input ng-model="companyEdit.companyPhone" ng-if="company.editActive" type="text" ng-init="companyEdit.companyPhone=company.companyPhone">
            </td>
            <td class="numeric">
              <a ng-if="!company.editActive" class="btn btn-info btn-xs updateuser edit " key={{company.companyId}} ng-click="updateCompany($index,company.companyId)"><i class="fa fa-edit"></i> 修改</a>
              <a ng-if="!company.editActive" class="btn btn-danger btn-xs delete" ng-click="delCompany(company.companyId)"><i class="fa fa-trash-o"></i> 删除</a>
              <a ng-if="company.editActive"  ng-click="sureUpdateCompany($index,company.companyId)" class="btn btn-success btn-xs save"><i class="fa fa-save"></i> 确认</a>
              <a ng-if="company.editActive"  ng-click="updateCompany($index,company.companyId)" class="btn btn-warning btn-xs cancel"><i class="fa fa-times"></i> 取消</a>
            </td>
          </tr>
          <tr ng-if="showAddCompany">
               <td></td>
                <td>
                  <input type="text" name="newCompanyName" ng-model="newCompany.companyName" required placeholder="名称"/>
                </td>
                <td>
                  <input type="text" name="newCompanyAddress" ng-model="newCompany.companyAddress" required placeholder="地址"/>
                </td>
                <td>
                  <input type="text" name="newCompanyRegion" ng-model="newCompany.companyRegion" required placeholder="所属地区"/>
                </td>
                <td>
                  <input type="text" name="newCompanyUser" ng-model="newCompany.companyUser" required placeholder="负责人"/>
                </td>
                <td>
                  <input type="text" name="newCompanyPhone" ng-model="newCompany.companyPhone" required placeholder="电话"/>
                </td>
                <td>
                  <button type="submit" class="btn btn-success btn-xs save"><i class="fa fa-save"></i>确认</button>
                  <a ng-click="addCompany()" class="btn btn-warning btn-xs cancel"><i class="fa fa-times"></i> 取消</a>
                </td>
            </tr>
        </tbody>
    </table>
    </form>
    <pagination ng-if="totalPage>1" current-page="currentPage" total-page="totalPage" get-record="getRecord()">
    </pagination>
  </div>
  <!-- 删除确认弹框 -->
  <div class="modal-preview "  ng-if="showModal">
    <div class="modal modal-primary">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" ng-click="delCompany()" data-dismiss="modal" aria-hidden="true">×</button>
            <h4 class="modal-title">删除公司信息</h4>
          </div>
          <div class="modal-body">
            <p>确认删除此公司信息？请谨慎操作！</p>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-warning" data-dismiss="modal" ng-click="delCompany()">取消</button>
            <button type="button" class="btn btn-primary" ng-click="sureDeleteCompany()">确认</button>
          </div>
        </div>
      </div>
    </div>
  </div>
  <div class="mask" ng-if="showModal"></div>
  <div class="clear"></div>
</div>
<script>
$(function() {
  $( ".modal-preview" ).draggable();
});
</script>
